<?php
    define('ABSOLUTE_SERVER_DOCUMENT_ROOT','../../');//admin

    if(file_exists('../../../definitions.inc.php')) include_once('../../../definitions.inc.php');
    include(ABSOLUTE_SERVER_DOCUMENT_ROOT.'session.inc');
    require_once('categorie_creator.inc');
    require_once(ABSOLUTE_SERVER_DOCUMENT_ROOT.'funct.inc');
    include ABSOLUTE_SERVER_DOCUMENT_ROOT.'color_style.php';
    include ABSOLUTE_SERVER_DOCUMENT_ROOT.LANGUAGE;
    
    if(!GetAdminID($ID)){echo LOGIN_ERR;exit;}
    if(!Right_Check(2)){header('Location:'.ABSOLUTE_SERVER_DOCUMENT_ROOT.'error.php');exit;}
    
    require_once(ABSOLUTE_SERVER_DOCUMENT_ROOT.'functs.inc');
    require_once('../../../classDB.inc.php');

?>
<html>
<head>
        <?php echo '<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET_.';">'; ?>

        <style  type="text/css"><!--
                table{
                        border-bottom-color: white;
                        border-top-color: black;
                        border-left-color: white;
                        border-right-color: white;
                        border-collapse: collapse;
                }
                input {
                        border: 0px;
                        cursor: hand;
                        height: 15px;
                        background-color: transparent;
                        font-size: 10px;
                        list-style-type: none;
                        font-family:  verdana;
                        text-align:left;
                        padding-left: 0px;
                        margin-left: 5px;
                        margin-top:0pt;
                        margin-bottom:0px;
                }
                form {margin-top:0pt; margin-bottom:0px;}
                img {margin-top:0pt; margin-bottom:0px;}
                body{
                        margin-left:0pt;
                        margin-right:0pt;
                        margin-top:0pt;
                        margin-bottom:0pt;
                        background-position:  15px 170px;
                        background-repeat:    no-repeat;
                }


        --></style>
</head>

<?php
print "<body bgcolor=\"".Background_Color."\">";
        
        $_DB = new classDB();
        if (!$_DB->open()){echo OPEN_DB_ERR; break;}

		$roll_menu="/";
		if($_REQUEST["roll_menu"]!="")
			$roll_menu=$_REQUEST["roll_menu"];
		if($_REQUEST["ID"]!="")
        	$roll_menu=rutine_menu($_REQUEST["roll_menu"],$_REQUEST["ID"]);
        
        
        //---------------------------------------------------------------------------
        //pridanie podmenu
        if($_REQUEST['TC_ID']!="" and $_REQUEST['Submenu_Caption']!="")
        	if (!Insert_Submenu($_REQUEST['TC_ID'],$_REQUEST['Submenu_Caption'])) print "";
        //---------------------------------------------------------------------------
        
        
        //---------------------------------------------------------------------------
        //premenovanie podmenu
        if($_REQUEST['Rename_Submenu_ID']!="" and $_REQUEST['Submenu_New_Caption']!="")
        	if (!Rename_Submenu($_REQUEST['Rename_Submenu_ID'],$_REQUEST['Submenu_New_Caption'])) print "";
        //---------------------------------------------------------------------------
        
        
        //---------------------------------------------------------------------------
        //odstranenie podmenu
        if($_REQUEST['Delete_Submenu_ID']!="")
        	if (!Delete_Submenu($_REQUEST['Delete_Submenu_ID'])) print "";
        //---------------------------------------------------------------------------
        
        
	//---------------------------------------------------------------------------       
        //nove hl. menu
        if($_REQUEST['Top_Menu_Caption']!="")
        	if (!Insert_Topmenu($_REQUEST['Top_Menu_Caption'])) print "";
        //---------------------------------------------------------------------------
        
        
        //---------------------------------------------------------------------------
        //premenovat hl. menu
        if($_REQUEST['Rename_Topbmenu_ID']!="" and $_REQUEST['Topmenu_New_Caption']!="")
        	if  (!Rename_Topmenu($_REQUEST['Rename_Topbmenu_ID'],$_REQUEST['Topmenu_New_Caption'])) print "";
        //---------------------------------------------------------------------------
        
        
        //---------------------------------------------------------------------------
        //vymazat hl. menu
        if($_REQUEST['Delete_Topmenu_ID']!="")
        	if (!Delete_Topmenu($_REQUEST['Delete_Topmenu_ID'])) print "";
        //---------------------------------------------------------------------------
        
        
        print "<b><font style=\"font-size:10px; font-family:verdana; position:absolute; left:5px; top:1px;\">".CPC_DEFINOVANIE_SPOSOBOV_DOPRAVY_A_PLATIEB.":</font></b>";
        print "<table cellpadding=\"0\" cellspacing=\"0\" style=\"position:absolute; left:5px; top:15px; border:0px;\">";
        //**********************************************************************
        //ROZROLOVANIE MENU PRI VYKRESLOVANI STRANKY - TOP MENU
        //**********************************************************************
        $sql_topmnu= "SELECT * FROM delivery_types";
        $TMnu_Source=mysql_query($sql_topmnu);
        while($sql_obj_delivery = mysql_fetch_object($TMnu_Source))
		{
			print "
				<tr style=\"background-color:".TR_BACKGOUND_COLOR_2.";\"
                                    onmouseover=\"this.style.backgroundColor='#FDE38A'; this.style.fontWeight='bold';\"
                                    onmouseout= \"this.style.backgroundColor='".TR_BACKGOUND_COLOR_2."'; this.style.fontWeight='normal';\"
				>
					<td colspan=\"2\">
						<form action=\"categorie_creator.php\" method=\"post\">
							<input type=\"hidden\" value=\"".$sql_obj_delivery->id."\" name=\"ID\" />
							<input type=\"submit\" value=\"".$sql_obj_delivery->dt_name."\" style=\"width :150px\";
							 onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bolder';\"
							 onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
							<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
						</form>
					</td>
					<td style=\"width:220px;\">";
						Rename_Topmenu_Form($_REQUEST['ShowAsTopMenuUpdate'],$sql_obj_delivery->id,$roll_menu); print"
					</td>
					<td style=\"width:220px;\">";
						Delete_Topmenu_Form($_REQUEST['ShowAsTopMenuDelete'],$sql_obj_delivery->id,$roll_menu); print"
					</td>
				</tr>";

            //**************************************************************
            //ak existuje SUB MENU a je rozrolovane
            //**************************************************************
            //tu sa vytvara zoznam formularov - zobrazenych ako podmenu
            if(is_roll($roll_menu,$sql_obj_delivery->id)){
                    $sql_submnu= "SELECT * FROM delivery_payment, payment_types WHERE dt_id=".$sql_obj_delivery->id." AND pt_id=payment_types.id";
                    $SMnu_Source=mysql_query("$sql_submnu");
                	while($sql_obj_payment = mysql_fetch_object($SMnu_Source))
                	{
                	  	print"
                      		<tr style=\"background-color:".TR_BACKGOUND_COLOR_1.";\"
                                    onmouseover=\"this.style.backgroundColor='#FFF4B9'; this.style.fontWeight='bold';\"
                                    onmouseout= \"this.style.backgroundColor='".TR_BACKGOUND_COLOR_1."'; this.style.fontWeight='normal';\"
                                >
                            	<td>
                              		-
                              	</td>
                              	<td>
                                	<form>
                                    	<input type=\"button\" value=\"".$sql_obj_payment->pt_name."\" style=\"width :120px\";
                                        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
                                        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
                                    	<input type=\"hidden\" value=\"".$sql_obj_payment->id."\" name=\"ID\" />
                                	</form>
                              	</td>
                              	<td style=\"width:220px;\">";
                              		//TLACITKO "PREMENOVAT" KU KAZDEJ POLOZKE
		                   			Rename_Submenu_Form($_REQUEST['ShowAsUpdate'],$sql_obj_payment->id,$roll_menu); print"
		                      	</td>
		                        <td style=\"width:220px;\">";
		                        	//TLACITKO "ODSTRANIT" KU KAZDEJ POLOZKE
		                   			Delete_Submenu_Form($_REQUEST['ShowAsDelete'],$sql_obj_payment->id,$roll_menu); print"
		                        </td>
                      		</tr>";
				}
				//ZOBRAZENIE TLACITKA NA PRIDANIE NOVEJ PODKATEGORIE:
				print "<tr style=\"background-color:".TR_BACKGOUND_COLOR_1.";\">";
					print "<td>";
				          //print "<img  src=\"L.png\" align=\"left\" alt=\"-\" border=\"0px\">";
				          print " - ";
				    print "</td>";
					print "<td colspan=\"3\">";
						New_Submenu_Form($_REQUEST['ShowAsNewSubCategory'],$sql_obj_delivery->id,$roll_menu);
				    print "</td>";
				print "</tr>";
         }
    }
	print "<tr style=\"background-color:".TR_BACKGOUND_COLOR_2.";\">";
	print "<td colspan=\"4\">";
		New_Topmenu_Form($_REQUEST['ShowAsNewTopCategory'],$roll_menu);
	print "</td>";
	print "</tr>";
	print "</table>";
	mysql_close();
?>
</body>
</html>
